/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CommonTools;

import java.io.Serializable;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * Класс, описывающий одну заявку
 * @author 555
 */

public class Demand implements Serializable{

    private int id;
    private String theme;
    private String subject;
    private Time time;
    private Time timeExec;
    private String stringTime;
    private String stringTimeExec;
    private String pc;
    private String comment;
    private String crit;
    private String user;
    private String status;
    protected Calendar c = Calendar.getInstance();
    private int tId;
    private int tIdExec;
    private boolean exec;

    /***************************************************
     * Конструктор
     **************************************************/

    public Demand(int id, String theme, String subject, String crit, String status, long time, long timeExec, String pc, String comment, int tId, int tIdExec, String user, boolean exec)
    {
        this.setId(id);
        this.setTheme(theme);
        this.setSubject(subject);
        this.setTime(time);
        this.setPc(pc);
        this.setComment(comment);
        this.setTId(tId);
        this.setExec(exec);
        this.setTimeExec(timeExec);
        this.setCrit(crit);
        this.setTIdExec(tIdExec);
        this.setUser(user);
        this.setStatus(status);
    }

    /***************************************************
     * Геттеры и сеттеры для каждой переменной
     **************************************************/

    public String getStatus()
    {
        return this.status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public String getUser()
    {
        return this.user;
    }

    public void setUser(String user)
    {
        this.user = user;
    }

    public int getTIdExec()
    {
        return this.tIdExec;
    }

    public long getTimeExec()
    {
        return this.timeExec.getTime();
    }

    public void setTIdExec(int tIdExec)
    {
        this.tIdExec = tIdExec;
    }

    public String getCrit()
    {
        return this.crit;
    }

    public void setCrit(String c)
    {
        this.crit = c;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return this.id;
    }

    public void setTheme(String theme)
    {
        this.theme = theme;
    }

    public String getTheme()
    {
        return this.theme;
    }

    public void setSubject(String subject)
    {
        this.subject = subject;
    }

    public String getSubject()
    {
        return this.subject;
    }

    public void setTime(long time)
    {
        Time t = new Time(time);
        c.setTimeInMillis(time);
        c.setTimeZone(TimeZone.getTimeZone("GMT+04:00"));
        this.time = t;

        Date d = new Date();
        d.setTime(time);

        DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm");
        this.stringTime = df.format(d);

        //this.stringTime = this.getDay() + "." + (this.getMonth() + 1) + "." + this.getYear() + " " + this.getHour() + ":" + this.getMinutes() + ":" + this.getSeconds();
    }

    public void setTimeExec(long time)
    {
        Time t = new Time(time);
        c.setTimeInMillis(time);
        c.setTimeZone(TimeZone.getTimeZone("GMT+04:00"));
        this.timeExec = t;

        Date d = new Date();
        d.setTime(time);

        DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm");
        this.stringTimeExec = df.format(d);

            //this.stringTimeExec = this.getDay() + "." + (this.getMonth() + 1) + "." + this.getYear() + " "
                    //+ this.getHour() + ":" + this.getMinutes() + ":" + this.getSeconds();
    }

    public Time getTime()
    {
        return this.time;
    }

    public String getTimeString()
    {
        return this.stringTime;
    }

    public String getTimeExecString()
    {
        return this.stringTimeExec;
    }

    private int getYear()
    {
        return c.get(Calendar.YEAR);
    }

    private int getDay()
    {
        return c.get(Calendar.DAY_OF_MONTH);
    }

    private int getMonth()
    {
        return c.get(Calendar.MONTH);
    }

    private int getHour()
    {
        return c.get(Calendar.HOUR);
    }

    private int getMinutes()
    {
        return c.get(Calendar.MINUTE);
    }

    private int getSeconds()
    {
        return c.get(Calendar.SECOND);
    }

    public void setPc(String pc)
    {
        this.pc = pc;
    }

    public String getPc()
    {
        return this.pc;
    }

    public void setComment(String comment)
    {
        this.comment = comment;
    }

    public String getComment()
    {
        return this.comment;
    }

    public void setTId(int tId)
    {
        this.tId = tId;
    }

    public int getTId()
    {
        return this.tId;
    }

    public void setExec(boolean exec)
    {
        this.exec = exec;
    }

    public boolean getExec()
    {
        return this.exec;
    }
}
